import os
import sys
import platform
from loguru import logger


if platform.system().lower() == 'linux':
    sys.path.append("/home/sacon/ChineseJournal/")

# 数据库相关
Redis_HOST = '192.168.44.53'
Redis_DB = 13
Redis_PASSWORD = 'vQLzqNlGA4z5hZBS'

ocr_code_url = "http://192.168.45.248:508/ocr?fujia="

raw_readingshow_transtion = "raw_readingshow_transtion_last_year"
raw_readingshow_bool_url = "raw_readingshow_bool_url_last_year"
# raw_readingshow_book = "raw_readingshow_detail_last_year"
raw_readingshow_book = "chinese_index_step04_index_detail_table_v2_0827_old"

proxies_list_gaoxiao = [
    {'https': 'http://YingKe:%yk123456%..@192.168.44.10:6231','http': 'http://YingKe:%yk123456%..@192.168.44.10:6231'},  # 北京大学()
    {'https': 'http://YingKe:%yk123456%..@192.168.44.10:6240','http': 'http://YingKe:%yk123456%..@192.168.44.10:6240'},  # 上海交通()
    {'https': 'http://YingKe:%yk123456%..@192.168.44.10:6214','http': 'http://YingKe:%yk123456%..@192.168.44.10:6214'},  # 广州大学()
]
waiwang_proxies_list = [
    {'https': 'http://192.168.44.149:7890', 'http': 'http://192.168.44.149:7890'},
    {'https': 'http://192.168.44.148:7890', 'http': 'http://192.168.44.148:7890'},
    {'https': 'http://192.168.44.147:7890', 'http': 'http://192.168.44.147:7890'},
    {'https': 'http://192.168.44.157:7890', 'http': 'http://192.168.44.157:7890'},
]


Mongo_HOST = '192.168.44.131'
Mongo_PORT = '27017'
Mongo_DB = 'ChineseJournalsCopy'
Mongo_USERNAME = 'ChineseJournalsCopy_admin'
Mongo_PASSWORD = 'Qk8XLTHBRAwndr4w'

## 表名
# redis_key = 'ChineseJournal:spider'
redis_key = 'ChineseJournal:spider1'
redis_key_cqvip_auth = 'ChineseJournal:Cqvip:authorization'


# html文件存放地址
if platform.system().lower() == 'linux':
    HtmlPath = '/home/sacon/ChineseJournal/html'
    sys.path.append("/home/sacon/ChineseJournal")
else:
    HtmlPath = r'D:\yingke\data\ChineseJournal\html'
if not os.path.exists(HtmlPath):
    try:
        os.makedirs(HtmlPath)
    except Exception as e:
        logger.error(f"存储html的文件夹创建失败:{e}！")

# pdf文件存放地址相关
if platform.system().lower() == 'linux':
    PdfPath = '/mnt/ChineseJournal'
    sys.path.append("/home/sacon/ChineseJournal")
else:
    PdfPath = r'D:\yingke\data\ChineseJournal\pdf'
if not os.path.exists(PdfPath):
    logger.error("下载文件不存在！")
    try:
        os.makedirs(PdfPath)
        logger.success("下载文件夹创建成功！")
    except Exception as e:
        logger.error(f"下载文件夹创建失败:{e}！")

DownloadPath = PdfPath

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if platform.system().lower() == 'linux':
    CACHE_DIR = '/mnt/20_超星读秀采集'
    sys.path.append("/mnt/20_超星读秀采集")
else:
    CACHE_DIR = os.path.join(BASE_DIR,"Config")
if not os.path.exists(CACHE_DIR):
    logger.error("下载文件不存在！")
    try:
        os.makedirs(CACHE_DIR)
        logger.success("下载文件夹创建成功！")
    except Exception as e:
        logger.error(f"下载文件夹创建失败:{e}！")

CACHE_DIR = CACHE_DIR

if platform.system().lower() == 'linux':
    IMAGE_DIR = '/mnt/20_超星读秀采集/临时文件/image'
    sys.path.append("/mnt/20_超星读秀采集")
else:
    IMAGE_DIR = os.path.join(BASE_DIR,"临时文件","image")
if not os.path.exists(IMAGE_DIR):
    logger.error("下载文件不存在！")
    try:
        os.makedirs(IMAGE_DIR)
        logger.success("下载文件夹创建成功！")
    except Exception as e:
        logger.error(f"下载文件夹创建失败:{e}！")

IMAGE_DIR = IMAGE_DIR

HeartDetectionKey = "25c484f0-eb74-4344-8b1d-dcf92792d89c"